/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pracamagisterska;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyVetoException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComponent;

/**
 *
 * @author Adrian
 */
class GlassPane extends JComponent {

        private ModalityInternalFrame modalFrame;

        public GlassPane(ModalityInternalFrame frame) {
            modalFrame = frame;
            addMouseListener(new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    if (modalFrame.isSelected() == false) {
                            try {
                                modalFrame.setSelected(true);
                                if (modalFrame.hasChildFrame() == false) {
                                    setVisible(false);
                                }
                            } catch (PropertyVetoException ex) {
                                Logger.getLogger(GlassPane.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                    }
                });
        }

        @Override
        public void paint(Graphics g) {
            super.paint(g);
            g.setColor(new Color(255, 255, 255, 100));
            g.fillRect(0, 0, getWidth(), getHeight());
        }
    }
